#include<student_info_management.h>
#include<course_management.h>
#include<read_data.h>
#include<log.h>
#include<map>
#include<iostream>

std::map<std::string,int> score;

Course_management Cour_mana;
Student_management Stu_mana;

FILE* log_file;


int main()
{
	log_file=fopen("log","w");

	Log("Reading init data");
	pre_read_data_courses();
	pre_read_data_students();


	int inst;
	std::string tnum;
	while(1)
	{
		printf("1.check student data\n");
		printf("2.add student data\n");
		printf("3.modify student data\n");
		printf("4.delete student data\n");
		printf("5.check course data\n");
		printf("6.add course data\n");
		printf("7.modify course data\n");
		printf("8.delete course data\n");
		printf("0.quit\n");
		scanf("%d",&inst);

		switch(inst)
		{
		case 1:
			printf("Input num:\n");
			std::cin>>tnum;
			Stu_mana.check_info(tnum);
			break;
		case 2:
			Stu_mana.add_info(read_student(1));
			break;
		case 3:
			printf("Input num:\n");
			std::cin>>tnum;
			Stu_mana.mod_info(tnum);
			break;
		case 4:
			printf("Input num:\n");
			std::cin>>tnum;
			Stu_mana.del_info(tnum);
			break;

		case 5:
			printf("Input num:\n");
			std::cin>>tnum;
			Cour_mana.check_info(tnum);
			break;
		case 6:
			Cour_mana.add_info(read_course(1));
			break;
		case 7:
			printf("Input num:\n");
			std::cin>>tnum;
			Cour_mana.mod_info(tnum);
			break;
		case 8:
			printf("Input num:\n");
			std::cin>>tnum;
			Cour_mana.del_info(tnum);
			break;

		case 0:
			printf("EXIT!\n");
			goto out;
		default:
			printf("INVALID INPUT\n");
			break;
		}
	}
out:
	Log("Writing data\n");
	write_students();
	write_courses();


	return 0;
}
